package oop.java0318;

import java.util.Scanner;

/**
 * 模拟实现用户密码管理：管理员有用户和密码两个属性，输入旧的用户名和密码，如果正确，方有权限更新；从键盘获取新的密码，进行更新
 */
public class Admin {
    String user = "admin";
    String pwd = "123456";

    //修改密码
    public void change() {
        Scanner in = new Scanner(System.in);
        System.out.print("用户名:");
        String user1 = in.next();
        System.out.print("密码:");
        String pwd1 = in.next();
        if (!user1.equals(user) || !pwd1.equals(pwd)) {
            System.out.println("登录失败！");
            return;
        }
        System.out.print("登录成功！\n请输入新密码:");
        pwd = in.next();
        System.out.println("修改成功！");

    }

    //展示信息
    public void show() {
        System.out.println("用户名：" + user + "\n密码：" + pwd);
    }
}
